mod picture;
mod camera;
mod brick;
mod space;
pub mod backend_glium;
mod shapes;

use std::rc::Rc;
use zmath::{Mat4, Vec3, Vec4, Vec2};

pub trait IProjector {
    fn set_scene(&mut self, space: &Space);
    fn play_film(&mut self, camera: &Camera);
}

#[repr(C)]
pub enum MaterialType {
    Bool(bool),
    Int(i32),
    Float(f32),
    Float2(Vec2),
    Float3(Vec3),
    Float4(Vec4),
    Texture(Picture)
}

pub trait IMaterial {
    fn set_attrib(&mut self, key: &str, attrib: MaterialType);
    fn shaders(&self) -> (&str, &str);
    fn texture(&self) -> Rc<Picture>;
}

pub enum DrawMode {
    Fill,
    Wire,
}

pub trait IShape {
    fn mode(&self) -> DrawMode;
    fn vertices(&self) -> &[f32];
    fn indices(&self) -> &[u32];
}

pub struct Picture {
    width: u16,
    height: u16,
    color_depth: u8,
    pixels: Vec<u8>,
}

pub struct Space {
    bricks: Vec<Brick>,
    bg_color: Vec4,
}

pub struct Brick {
    position: Vec3,
    shape: Rc<dyn IShape>,
    material: Rc<dyn IMaterial>,
}

pub struct Camera {
    position: Vec3,
    projection: Mat4,
}
